import { MOCK_ADMINS } from '~/utils/mock-data';

export default defineEventHandler(async (event) => {
  const { password, username, realName, roles, id } = await readBody(event);

  const user = {
    id,
    username,
    realName,
    password,
    roles,
  };
  const index = MOCK_ADMINS.findIndex((item) => item.id === user.id);
  if (index !== -1) {
    MOCK_ADMINS[index] = user;
  }
  return useResponseSuccess(null);
});
